<?php

class Course extends AppModel {
	var $name= 'Course';
	
	//ACL this is a crontrolled object ACO
	var $actsAs = array('Acl' => array('type' => 'controlled'));
	
	function parentNode() {
		if (!$this->id && empty($this->data)) {
			return null;
		}
		if (isset($this->data['Course']['courselist_id'])) {
			$clId = $this->data['Course']['courselist_id'];
		} else {
			$clId = $this->field('courselist_id');
		}
		if (!$clId) {
			return null;
		} else {
			return array('Courselist' => array('id' => $clId));
		}
	}
	
	var $validate = array(
		'coursename' => array(
			'rule' => 'notempty',
			'message' => 'Coursename required'
		),
		'grade' => array(
			'rule' => 'notempty',
			'message' => 'grade required'
		)
	);
		
	
/**
* START ASSOCIATION INFORMATION
******************************************************************************
*/
 	 	
 	var $belongsTo = array(
 		'Courselist' => array(
 			'className' => 'Courselist',
			'foreignKey' => 'courselist_id'
		)
	); //end belongsTo array.

}
